//
// Copyright (C) 2009 Ben Jaques.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this
//   list of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice,
//   this list of conditions and the following disclaimer in the documentation
//   and/or other materials provided with the distribution.
//
// - Neither the name of the author nor the names of its contributors may be used
//   to endorse or promote products derived from this software without specific
//   prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//

/*
 * ReviewPanel.java
 *
 * Created on Sep 1, 2009, 5:25:21 PM
 */

package uk.co.massycat.appreviewsfinder.reviews;

import java.awt.Font;
import uk.co.massycat.appreviewsfinder.*;
import javax.swing.JButton;

/**
 *
 * @author ben
 */
public class ReviewPanel extends javax.swing.JPanel {
    public int mReviewNumber;
    private TranslationButtonListener mTransListener;
    public static final String TRANSLATE_STRING = "Translate";
    public static final String ORIGINAL_STRING = "Original";

    public void setTranslation( boolean translation) {
        if ( translation) {
            mTranslateButton.setText(TRANSLATE_STRING);
        }
        else {
            mTranslateButton.setText(ORIGINAL_STRING);
        }
    }

    public String getTranslation() {
        return mTranslateButton.getText();
    }

    public JButton getTranslateButton() {
        return mTranslateButton;
    }

    private void setupFont() {
        // set the font to sans serif
        Font sans_serif = new Font( Font.SANS_SERIF, Font.PLAIN, 14);
        Font sans_serif_bold = new Font( Font.SANS_SERIF, Font.BOLD, 14);

        mTitle.setFont(sans_serif_bold);
        mSubTitle.setFont(sans_serif_bold);
        mReviewTextArea.setFont(sans_serif);
    }

    /** Creates new form ReviewPanel */
    public ReviewPanel() {
        mTransListener = null;
        initComponents();

        //setupFont();
    }
    public ReviewPanel( TranslationButtonListener trans_listener) {
        mTransListener = trans_listener;
        initComponents();

        //setupFont();
    }

    public javax.swing.JLabel getTitleLabel() {
        return mTitle;
    }

    public javax.swing.JLabel getSubTitleLabel() {
        return mSubTitle;
    }

    public javax.swing.JTextArea getReviewArea() {
        return mReviewTextArea;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        mReviewTextArea = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        mTitle = new javax.swing.JLabel();
        mSubTitle = new javax.swing.JLabel();
        mTranslateButton = new javax.swing.JButton();

        setLayout(new java.awt.BorderLayout());
        add(jSeparator1, java.awt.BorderLayout.PAGE_END);

        jScrollPane1.setPreferredSize(new java.awt.Dimension(200, 84));

        mReviewTextArea.setColumns(50);
        mReviewTextArea.setEditable(false);
        mReviewTextArea.setLineWrap(true);
        mReviewTextArea.setRows(5);
        mReviewTextArea.setWrapStyleWord(true);
        jScrollPane1.setViewportView(mReviewTextArea);

        add(jScrollPane1, java.awt.BorderLayout.CENTER);

        jPanel2.setLayout(new java.awt.BorderLayout());

        jPanel1.setLayout(new java.awt.GridLayout(2, 0));

        mTitle.setText("jLabel1");
        mTitle.setOpaque(true);
        jPanel1.add(mTitle);

        mSubTitle.setText("jLabel1");
        jPanel1.add(mSubTitle);

        jPanel2.add(jPanel1, java.awt.BorderLayout.CENTER);

        mTranslateButton.setText("Translate");
        mTranslateButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mTranslateButtonActionPerformed(evt);
            }
        });
        jPanel2.add(mTranslateButton, java.awt.BorderLayout.EAST);

        add(jPanel2, java.awt.BorderLayout.NORTH);
    }// </editor-fold>//GEN-END:initComponents

    private void mTranslateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mTranslateButtonActionPerformed
        if ( mTransListener != null) {
            mTransListener.translationRequested(this);
        }
    }//GEN-LAST:event_mTranslateButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextArea mReviewTextArea;
    private javax.swing.JLabel mSubTitle;
    private javax.swing.JLabel mTitle;
    private javax.swing.JButton mTranslateButton;
    // End of variables declaration//GEN-END:variables

}
